

<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="" > <!--<![endif]-->
<head>
  <meta charset="utf-8">
  
  <meta name="viewport" content="width=device-width, initial-scale=1.0">

  
  <title>The PhysX API &mdash; NVIDIA PhysX SDK 4.1 Documentation</title>
  

  
  <link rel="shortcut icon" href="_static/images/favicon.ico"/>

  
  

  

  
  
    

  
  <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
  <link rel="stylesheet" href="../_static/breathe.css" type="text/css" />
    <link rel="next" title="Startup and Shutdown" href="Startup.html" />
    <link rel="prev" title="Building with PhysX" href="BuildingWithPhysX.html" />
    <link href="../_static/css/nvidia_theme.css" rel="stylesheet" type="text/css">
    
    
        <style>
            .wy-nav-content::before {
                content: "PhysX 4.1 SDK Guide";
            }
        </style>
    


  
  <script src="../_static/js/modernizr.min.js"></script>

</head>

<body class="wy-body-for-nav">

   
  <div class="wy-grid-for-nav">

    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side">
      <div class="wy-side-scroll">
        <div class="wy-side-nav-search">
          

          
            <a href="../Index.html" class="icon icon-home"> Python
          

          
          </a>

          

          
<div role="search">
  <form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" />
    <input type="hidden" name="check_keywords" value="yes" />
    <input type="hidden" name="area" value="default" />
  </form>
</div>

          
        </div>

        <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
          
            
            
              
            
            
              <ul class="current">
<li class="toctree-l1 current"><a class="reference internal" href="Index.html">User's Guide</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="License.html">PhysX License</a></li>
<li class="toctree-l2"><a class="reference internal" href="Introduction.html">Welcome to PhysX</a></li>
<li class="toctree-l2"><a class="reference internal" href="HelloWorld.html">Snippets</a></li>
<li class="toctree-l2"><a class="reference internal" href="BuildingWithPhysX.html">Building with PhysX</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="">The PhysX API</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#introduction">Introduction</a></li>
<li class="toctree-l3"><a class="reference internal" href="#memory-management">Memory Management</a></li>
<li class="toctree-l3"><a class="reference internal" href="#error-reporting">Error Reporting</a></li>
<li class="toctree-l3"><a class="reference internal" href="#math-classes">Math Classes</a></li>
<li class="toctree-l3"><a class="reference internal" href="#connecting-physx-objects-with-user-application-objects">Connecting PhysX Objects with User Application Objects</a></li>
<li class="toctree-l3"><a class="reference internal" href="#type-casting">Type Casting</a></li>
<li class="toctree-l3"><a class="reference internal" href="#reference-counting">Reference Counting</a></li>
<li class="toctree-l3"><a class="reference internal" href="#using-different-units">Using Different Units</a></li>
<li class="toctree-l3"><a class="reference internal" href="#assertions">Assertions</a></li>
<li class="toctree-l3"><a class="reference internal" href="#determinism">Determinism</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="Startup.html">Startup and Shutdown</a></li>
<li class="toctree-l2"><a class="reference internal" href="Threading.html">Threading</a></li>
<li class="toctree-l2"><a class="reference internal" href="Geometry.html">Geometry</a></li>
<li class="toctree-l2"><a class="reference internal" href="RigidBodyOverview.html">Rigid Body Overview</a></li>
<li class="toctree-l2"><a class="reference internal" href="RigidBodyCollision.html">Rigid Body Collision</a></li>
<li class="toctree-l2"><a class="reference internal" href="RigidBodyDynamics.html">Rigid Body Dynamics</a></li>
<li class="toctree-l2"><a class="reference internal" href="Simulation.html">Simulation</a></li>
<li class="toctree-l2"><a class="reference internal" href="AdvancedCollisionDetection.html">Advanced Collision Detection</a></li>
<li class="toctree-l2"><a class="reference internal" href="Joints.html">Joints</a></li>
<li class="toctree-l2"><a class="reference internal" href="Articulations.html">Articulations</a></li>
<li class="toctree-l2"><a class="reference internal" href="Articulations.html#maximal-coordinate-and-reduced-articulations">Maximal Coordinate and Reduced Articulations</a></li>
<li class="toctree-l2"><a class="reference internal" href="Articulations.html#maximal-coordinate-articulations">Maximal Coordinate Articulations</a></li>
<li class="toctree-l2"><a class="reference internal" href="Articulations.html#reduced-coordinate-articulations">Reduced Coordinate Articulations</a></li>
<li class="toctree-l2"><a class="reference internal" href="OriginShift.html">Scene Origin</a></li>
<li class="toctree-l2"><a class="reference internal" href="GPURigidBodies.html">GPU Rigid Bodies</a></li>
<li class="toctree-l2"><a class="reference internal" href="GeometryQueries.html">Geometry Queries</a></li>
<li class="toctree-l2"><a class="reference internal" href="SceneQueries.html">Scene Queries</a></li>
<li class="toctree-l2"><a class="reference internal" href="Vehicles.html">Vehicles</a></li>
<li class="toctree-l2"><a class="reference internal" href="CharacterControllers.html">Character Controllers</a></li>
<li class="toctree-l2"><a class="reference internal" href="DebugVisualization.html">Debug Visualization</a></li>
<li class="toctree-l2"><a class="reference internal" href="VisualDebugger.html">PhysX Visual Debugger (PVD)</a></li>
<li class="toctree-l2"><a class="reference internal" href="Statistics.html">Simulation Statistics</a></li>
<li class="toctree-l2"><a class="reference internal" href="Serialization.html">Serialization</a></li>
<li class="toctree-l2"><a class="reference internal" href="ExtendingSerialization.html">Extending Serialization</a></li>
<li class="toctree-l2"><a class="reference internal" href="BestPractices.html">Best Practices Guide</a></li>
<li class="toctree-l2"><a class="reference internal" href="MigrationFrom28.html">Migrating From PhysX SDK 2.x to 3.x</a></li>
<li class="toctree-l2"><a class="reference internal" href="MigrationTo33.html">Migrating From PhysX SDK 3.2 to 3.3</a></li>
<li class="toctree-l2"><a class="reference internal" href="MigrationTo34.html">Migrating From PhysX SDK 3.3 to 3.4</a></li>
<li class="toctree-l2"><a class="reference internal" href="MigrationTo40.html">Migrating From PhysX SDK 3.4 to 4.0</a></li>
</ul>
</li>
</ul>

            
          
        </div>
      </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" aria-label="top navigation">
        
          <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
          <a href="../Index.html">Python</a>
        
      </nav>


      <div class="wy-nav-content">
        
        <div class="rst-content">
        
          















<div role="navigation" aria-label="breadcrumbs navigation">

  <ul class="wy-breadcrumbs">
    
      <li><a href="../Index.html">Docs</a> &raquo;</li>
        
          <li><a href="Index.html">User's Guide</a> &raquo;</li>
        
      <li>The PhysX API</li>
    
    
      <li class="wy-breadcrumbs-aside">
        
            
        
      </li>
    
  </ul>

  
  <hr/>
</div>
          <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
           <div itemprop="articleBody">
            
  <div class="section" id="the-physx-api">
<span id="api"></span><h1>The PhysX API<a class="headerlink" href="#the-physx-api" title="Permalink to this headline">¶</a></h1>
<div class="section" id="introduction">
<h2>Introduction<a class="headerlink" href="#introduction" title="Permalink to this headline">¶</a></h2>
<p>This chapter covers the basic patterns common to the PhysX application programming interface (API.) We are committed to keeping this API stable and backwards-compatible from one minor release to the next, to protect the investment you make in your integration code.</p>
<p>The PhysX API is composed primarily of abstract interface classes. Classes, enumerations and functions defined by the API have the prefix Px.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">There is currently one section of the public API which does not have the Px prefix: the PhysX Visual Debugger connection library which has the prefix Pvd.</p>
</div>
<p>The PhysX libraries also expose some classes and functions that are not part of the public API. These are primarily containers and platform abstractions that are required to build the PhysX libraries which are distributed as source, and are also used in the samples. They can be recognized because they do not have the Px prefix. Even though they are in principle accessible to users, they are largely undocumented and we do not maintain compatibility of this code between PhysX versions. For that reason we recommend strongly against their use in applications.</p>
</div>
<div class="section" id="memory-management">
<span id="memorymanagement"></span><h2>Memory Management<a class="headerlink" href="#memory-management" title="Permalink to this headline">¶</a></h2>
<p>PhysX performs all allocations via the <em>PxAllocatorCallback</em> interface. You must implement this interface in order to initialize PhysX:</p>
<div class="highlight-c++"><div class="highlight"><pre><span class="k">class</span> <span class="nc">PxAllocatorCallback</span>
<span class="p">{</span>
<span class="nl">public:</span>
    <span class="k">virtual</span> <span class="o">~</span><span class="n">PxAllocatorCallback</span><span class="p">()</span> <span class="p">{}</span>
    <span class="k">virtual</span> <span class="kt">void</span><span class="o">*</span> <span class="n">allocate</span><span class="p">(</span><span class="kt">size_t</span> <span class="n">size</span><span class="p">,</span> <span class="k">const</span> <span class="kt">char</span><span class="o">*</span> <span class="n">typeName</span><span class="p">,</span> <span class="k">const</span> <span class="kt">char</span><span class="o">*</span> <span class="n">filename</span><span class="p">,</span>
        <span class="kt">int</span> <span class="n">line</span><span class="p">)</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
    <span class="k">virtual</span> <span class="kt">void</span> <span class="n">deallocate</span><span class="p">(</span><span class="kt">void</span><span class="o">*</span> <span class="n">ptr</span><span class="p">)</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>
<span class="p">};</span>
</pre></div>
</div>
<p>The size of the request is specified in bytes, and PhysX requires that the memory that is returned be 16-byte aligned.  On many platforms malloc() returns memory that is 16-byte aligned, and on Windows the system function _aligned_malloc() provides this capability. The other parameters to allocate() are a string which identifies the type of allocation, and the __FILE__ and __LINE__ location inside PhysX code where the allocation was made. Refer to PxAllocatorCallback::allocate() to find out more about them.</p>
<p>A simple implementation of the allocator callback class can be found in the PhysX Extensions library, see class <em>PxDefaultAllocatorCallback</em>.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">On some platforms PhysX uses system library calls to determine the correct type name, and the system function that returns the type name may call the system memory allocator. If you are instrumenting system memory allocations, you may observe this behavior. To prevent PhysX requesting type names, disable allocation names using the method PxFoundation::setReportAllocationNames().</p>
</div>
<p>You can place PhysX objects in memory owned by the application using PhysX' binary deserialization mechanism. See <a class="reference internal" href="Serialization.html#serialization"><em>Serialization</em></a> for details.</p>
<p>As an alternative to instrumenting the allocator, you can obtain detailed information about memory allocation in the PhysX Visual Debugger (see: <a class="reference internal" href="VisualDebugger.html#physxvisualdebugger"><em>PhysX Visual Debugger (PVD)</em></a>)</p>
</div>
<div class="section" id="error-reporting">
<span id="errorreporting"></span><h2>Error Reporting<a class="headerlink" href="#error-reporting" title="Permalink to this headline">¶</a></h2>
<p>PhysX logs all error messages through the <em>PxErrorCallback</em> interface. You must implement this interface in order to initialize PhysX:</p>
<div class="highlight-c++"><div class="highlight"><pre><span class="k">class</span> <span class="nc">UserErrorCallback</span> <span class="o">:</span> <span class="k">public</span> <span class="n">PxErrorCallback</span>
<span class="p">{</span>
<span class="nl">public:</span>
    <span class="k">virtual</span> <span class="kt">void</span> <span class="n">reportError</span><span class="p">(</span><span class="n">PxErrorCode</span><span class="o">::</span><span class="n">Enum</span> <span class="n">code</span><span class="p">,</span> <span class="k">const</span> <span class="kt">char</span><span class="o">*</span> <span class="n">message</span><span class="p">,</span> <span class="k">const</span> <span class="kt">char</span><span class="o">*</span> <span class="n">file</span><span class="p">,</span>
        <span class="kt">int</span> <span class="n">line</span><span class="p">)</span>
    <span class="p">{</span>
        <span class="c1">// error processing implementation</span>
        <span class="p">...</span>
    <span class="p">}</span>
<span class="p">};</span>
</pre></div>
</div>
<p>There is only a single function to implement, <em>reportError</em>.  This function should log the passed message, or print it on the application's output console. For the more serious error codes <em>eABORT</em>, <em>eINVALID_PARAMETER</em>, <em>eINVALID_OPERATION</em>, <em>eINTERNAL_ERROR</em> and <em>eOUT_OF_MEMORY</em>, breaking into the debugger may be a more appropriate choice.  Whatever you do, do not just ignore the messages.</p>
<p>A simple implementation of the error callback class can be found in the PhysX Extensions library, see class <em>PxDefaultErrorCallback</em>.</p>
</div>
<div class="section" id="math-classes">
<span id="mathtypes"></span><h2>Math Classes<a class="headerlink" href="#math-classes" title="Permalink to this headline">¶</a></h2>
<p>The common math classes used in PhysX are PxVec2, PxVec3, PxVec4, PxMat33, PxMat44, PxTransform, PxPlane and PxQuat, which are are defined in their respective header files, e.g. (SDKRoot)/Include/foundation/PxVec3.h. The types support standard operator overloads and typical math operations. Zero and identity objects where appropriate can be constructed by passing the arguments PxZero and PxIdentity respectively.</p>
<p>Some points to note are:</p>
<ul class="simple">
<li>PxTransform is a representation of a rigid body transform as a rotation quaternion and a position vector, and PhysX functions which take transforms all use this type.</li>
<li>PxPlane is a homogeneous plane equation: that is, the constructor PxPlane(n, d) represents the equation n.x + d = 0.</li>
</ul>
<p>PxMat33 and PxMat44 matrices represent transformations with basis vectors in the columns (pre-multiply with matrix on the left hand side) and are stored in column-major order. This format is layout compatible with popular graphics APIs such as OpenGL and Direct3D. For example, to set the model transformation for a rigid body in OpenGL:</p>
<div class="highlight-c++"><div class="highlight"><pre><span class="c1">// retrieve world space transform of rigid body</span>
<span class="n">PxTransform</span> <span class="n">t</span> <span class="o">=</span> <span class="n">rigidActor</span><span class="p">.</span><span class="n">getGlobalPose</span><span class="p">();</span>

<span class="c1">// convert to matrix form</span>
<span class="n">PxMat44</span> <span class="n">m</span> <span class="o">=</span> <span class="n">PxMat44</span><span class="p">(</span><span class="n">t</span><span class="p">);</span>

<span class="c1">// set to OpenGL</span>
<span class="n">glMatrixMode</span><span class="p">(</span><span class="n">GL_MODELVIEW</span><span class="p">);</span>
<span class="n">glPushMatrix</span><span class="p">();</span>

<span class="c1">// PxMat44::front() returns a pointer to the first matrix element</span>
<span class="n">glMultMatrixf</span><span class="p">(</span><span class="n">m</span><span class="p">.</span><span class="n">front</span><span class="p">());</span>

<span class="c1">// draw model</span>

<span class="n">glPopMatrix</span><span class="p">()</span>
</pre></div>
</div>
<p>DirectX uses row-major storage for matrices by default (D3DMATRIX), but also stores basis vectors in rows (post-multiply on the right), so PxMat44 may be used in place of D3DXMATRIX types directly.</p>
</div>
<div class="section" id="connecting-physx-objects-with-user-application-objects">
<span id="userdata"></span><h2>Connecting PhysX Objects with User Application Objects<a class="headerlink" href="#connecting-physx-objects-with-user-application-objects" title="Permalink to this headline">¶</a></h2>
<p>Often an application needs to associate PhysX objects with application objects for application logic or rendering purposes. An easy way to connect a single user application object with a PhysX object is to use the <em>userData</em> member provided by the most important PhysX classes (<em>PxActor::userData</em>, <em>PxShape::userData</em>, <em>PxMaterial::userData</em>, ...). The <em>userData</em> member is a <em>void*</em> pointer which is reserved for application use. Each class only has one <em>userData</em> field, so to manage multiple associations another mechanism must be used.</p>
</div>
<div class="section" id="type-casting">
<h2>Type Casting<a class="headerlink" href="#type-casting" title="Permalink to this headline">¶</a></h2>
<p>PhysX API interface classes inherit from a top-level interface called PxBase, which provides mechanisms for type-safe down-casting between interface types. For example, to cast from a PxActor to a PxRigidDynamic, use the following idiom:</p>
<div class="highlight-c++"><div class="highlight"><pre><span class="n">PxActor</span><span class="o">*</span> <span class="n">actor</span> <span class="o">=</span> <span class="o">&lt;</span><span class="p">...</span><span class="o">&gt;</span>
<span class="n">PxRigidDynamic</span><span class="o">*</span> <span class="n">myActor</span> <span class="o">=</span> <span class="n">actor</span><span class="o">-&gt;</span><span class="n">is</span><span class="o">&lt;</span><span class="n">PxRigidDynamic</span><span class="o">&gt;</span><span class="p">();</span>

<span class="k">const</span> <span class="n">PxActor</span><span class="o">*</span> <span class="n">actor</span> <span class="o">=</span> <span class="o">&lt;</span><span class="p">...</span><span class="o">&gt;</span>
<span class="k">const</span> <span class="n">PxRigidDynamic</span><span class="o">*</span> <span class="n">myActor</span> <span class="o">=</span> <span class="n">actor</span><span class="o">-&gt;</span><span class="n">is</span><span class="o">&lt;</span><span class="n">PxRigidDynamic</span><span class="o">&gt;</span><span class="p">();</span>
</pre></div>
</div>
<p>This pattern can be used to cast to intermediate types in the hierarchy such as PxRigidActor, but this is somewhat slower than casting to concrete types. In addition, PxBase provides the following capabilities:</p>
<ul class="simple">
<li>getConcreteType() provides an integer value which corresponds to the concrete type of an object</li>
<li>getConcreteTypeName() provides a string name of the concrete type</li>
<li>isKindOf() provides string-based testing of inheritance</li>
</ul>
</div>
<div class="section" id="reference-counting">
<span id="basicreferencecounting"></span><h2>Reference Counting<a class="headerlink" href="#reference-counting" title="Permalink to this headline">¶</a></h2>
<p>Some PhysX objects are designed to be shared and referenced multiple times in a PhysX scene graph. For example, a PxConvexMesh may be referenced by multiple PxShape objects, each sharing the same geometry but associated with different actors. The specific types are PxTriangleMesh, PxHeightField, PxConvexMesh, PxMaterial, and PxShape. Each object of these types has a reference count. The rules for reference counting are as follows:</p>
<ul class="simple">
<li>when an object is created from PxPhysics, it has a reference count of 1.</li>
<li>when an object's reference count reaches 0, the object is destroyed.</li>
<li>when a new counted reference is created, the reference count is incremented. Counted references are as follows:<ul>
<li>when a PxShape references a PxConvexMesh, PxHeightfield, or PxTriangleMesh.</li>
<li>when a PxShape references a PxMaterial.</li>
<li>when a PxRigidActor references a PxShape.</li>
</ul>
</li>
<li>when a counted reference is destroyed, or the object's release() method is called, the reference count is decremented.</li>
<li>when an object is created through deserialization, its reference count is 1, plus the number of counted references that exist to the object.</li>
</ul>
<p>The initial reference count of 1 ensures the object is not destroyed until the application allows it by calling release() - thereafter it will be destroyed when no remaining counted references to it exist.</p>
<p>For example, if you create a shape using PxPhysics::createShape() and attach it to an actor with PxRigidActor::attachShape(), it has a reference count of 2. If you then call the shape's
release() method, it has a reference count of 1. When the actor is destroyed, or the shape is detached from the actor, the reference count is decremented, and since it is now 0, the shape is destroyed.</p>
<p>The acquireReference() method increments the reference count of an object. For example, when a spatial query returns a reference to a mesh shape, and you want to pass that result to another thread for deferred processing, incrementing the reference count will ensure that even if the shape referencing the mesh is released, the mesh continues to exist.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">subtypes of PxGeometry do not have counted references to the meshes to which they point, e.g. when PxConvexMeshGeometry points to a PxConvexMesh. A counted reference exists only when the geometry is within a PxShape.</p>
</div>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">shapes are often created using the utility method PxRigidActorExt::createExclusiveShape(). Take special care when deserializing such actors (see <a class="reference internal" href="RigidBodyCollision.html#rigidbodycollisionshapes"><em>Shapes</em></a> and <a class="reference internal" href="Serialization.html#deserializereferencecounting"><em>Reference Counting of Deserialized Objects</em></a>)</p>
</div>
</div>
<div class="section" id="using-different-units">
<span id="pxtolerancescale"></span><h2>Using Different Units<a class="headerlink" href="#using-different-units" title="Permalink to this headline">¶</a></h2>
<p>PhysX is designed to produce correct results regardless of the units of length or mass, so long as inputs use those units consistently. However, there are certain tolerances values whose defaults need to be adjusted depending on the units. In order to ensure that these tolerances default to reasonable values, adjust the values in PxTolerancesScale when creating the PxPhysics and PxCooking interfaces. Tolerances for objects are set at creation time, and may then be overridden by the application.</p>
<p>You should set tolerances based on the typical size of objects in your simulation. For example, if you are working with objects of size approximately one meter, but in units of centimeters, you should set the scale as follows:</p>
<div class="highlight-c++"><div class="highlight"><pre><span class="n">PxFoundation</span><span class="o">*</span> <span class="n">foundation</span> <span class="o">=</span> <span class="p">...;</span>
<span class="n">PxTolerancesScale</span> <span class="n">scale</span><span class="p">;</span>
<span class="n">scale</span><span class="p">.</span><span class="n">length</span> <span class="o">=</span> <span class="mi">100</span><span class="p">;</span>        <span class="c1">// typical length of an object</span>
<span class="n">scale</span><span class="p">.</span><span class="n">speed</span> <span class="o">=</span> <span class="mi">981</span><span class="p">;</span>         <span class="c1">// typical speed of an object, gravity*1s is a reasonable choice</span>
<span class="n">PxPhysics</span> <span class="o">*</span><span class="n">p</span> <span class="o">=</span> <span class="n">PxCreatePhysics</span><span class="p">(</span><span class="n">PX_PHYSICS_VERSION</span><span class="p">,</span> <span class="o">*</span><span class="n">foundation</span><span class="p">,</span> <span class="n">scale</span><span class="p">,</span> <span class="p">...);</span>
</pre></div>
</div>
<p>This will result in the defaults for values like PxShape::contactDistance being scaled appropriately for your objects.</p>
<p>You can also set the typical object mass in PxTolerancesScale.</p>
<p>It is important to use the same PxTolerances value for initialization of PxCooking and PxPhysics, and also when creating PxSceneDesc objects.</p>
</div>
<div class="section" id="assertions">
<span id="id1"></span><h2>Assertions<a class="headerlink" href="#assertions" title="Permalink to this headline">¶</a></h2>
<p>PhysX uses the PX_DEBUG macro to enable or disable assertions. This macro is not set in the PhysXCore and PhysXCommon libraries, and so by default these libraries will not trigger assertions, however you may configure the libraries provided as source to enable them. When an assert is triggered, PhysX calls an assert handler. By default the assert handler will trigger a debug breakpoint. However, you may call the function PxSetAssertHandler() to customize the assert handler.</p>
</div>
<div class="section" id="determinism">
<h2>Determinism<a class="headerlink" href="#determinism" title="Permalink to this headline">¶</a></h2>
<p>PhysX is deterministic in the sense it will produce identical simulation results from the same sequence of API calls applied from the point where a scene is originally created (and the same responses from simulation callbacks which modify data). Note that removing all the objects from a scene is not in general sufficient to reinitialize it for this purpose.</p>
<p>PhysX simulation behavior is not sensitive to the number of CPU worker threads used.</p>
<p>An important caveat to determinism is the state of the x87 FPU on 32-bit Intel/AMD platforms. Some compilers produce x87 floating point instructions even when configured to prefer SSE instructions, and the results of those operations may depend on the state of the x87 control word.  Since it is too expensive to modify the x87 FPU state at every PhysX entry point, this is delegated to the application if necessary. PhysX operations do not result in changes to the x87 control word, but certain other libraries (including DirectX) may modify it.</p>
<p>Configurations in which this is known to be a issue are all 32-bit MSVC debug configurations, and all MSVC 32-bit checked, release and profile configurations prior to Visual Studio 2012.</p>
</div>
</div>


           </div>
           
          </div>
          <footer>
  
    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
      
        <a href="Startup.html" class="btn btn-neutral float-right" title="Startup and Shutdown" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
      
      
        <a href="BuildingWithPhysX.html" class="btn btn-neutral" title="Building with PhysX" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
      
    </div>
  

  <hr/>

  <div role="contentinfo">
    <p>
        &copy; Copyright 2008-2021 NVIDIA Corporation, 2788 San Tomas Expressway, Santa Clara, CA 95051 U.S.A. All rights reserved

    </p>
  </div> 

</footer>

        </div>
      </div>

    </section>

  </div>
  


  

    
    
      <script type="text/javascript">
          var DOCUMENTATION_OPTIONS = {
              URL_ROOT:'../',
              VERSION:'4.1',
              LANGUAGE:'',
              COLLAPSE_INDEX:false,
              FILE_SUFFIX:'.html',
              HAS_SOURCE:  true,
              SOURCELINK_SUFFIX: ''
          };
      </script>
        <script type="text/javascript" src="../_static/jquery.js"></script>
        <script type="text/javascript" src="../_static/underscore.js"></script>
        <script type="text/javascript" src="../_static/doctools.js"></script>
    

  

  <script type="text/javascript" src="../_static/js/theme.js"></script>

  <script type="text/javascript">
      jQuery(function () {
          SphinxRtdTheme.Navigation.enable(false);
      });
  </script> 

</body>
</html>